<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>你好，探险家</title>

<%@ include file="static_res.jsp"%>
<script>
	$(function() {
		$("#loginBtn").click(
				function() {
					if ($('#username').val() == "") {
						Materialize.toast('账号不能为空 ！', 3000);
						return;
					}
					if ($('#pwd').val() == "") {
						Materialize.toast('密码不能为空 ！', 3000);
						return;
					}

					var param = "username=" + $("#username").val() + "&pwd="
							+ $("#pwd").val();
					$.ajax({
						type : "POST",
						url : "<%=path%>/user/login.do",
						data : param,
						dateType : "text",
						success : function(result) {
							if ("3" == result)
								Materialize.toast('账号不存在 ！', 3000);
							else if ("2" == result)
								Materialize.toast('密码不正确 ！', 3000);
							else
								location.href = "<%=path%>/article/mainData";
						}
					});
				});
	});
</script>

</head>
<body>
	<div class="container">

		<div class="section"></div>
		<div class="section"></div>
		<div class="section"></div>
		<div class="section"></div>
		<div class="row">
			<div class="col s4 offset-s4">
				<div class="card hoverable">
					<div class="card-content black-text">
						<span class="card-title">登录</span>
						<div class="row"></div>
						<div class="input-field">
							<input id="username" name="username" type="text"> <label
								for="username">账号</label>
						</div>

						<div class="input-field">
							<input id="pwd" name="pwd" type="password"> <label for="pwd">密码</label>
						</div>
					</div>
					<div class="card-action center-align">
						<a href="<%=path%>/jsp/register.jsp">注册</a>
						<a id="loginBtn" href="#">登录</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>